﻿using B.S.Traceability.Domain;
using B.S.Traceability.Error;
using B.S.Traceability.Writer.API.Application.Commends.Farmss;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace B.S.Traceability.Writer.API.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class FarmsController : ControllerBase
    {

        private readonly IMediator mediator;

        public FarmsController(IMediator mediator)
        {
            this.mediator = mediator;
        }


        /// <summary>
        /// 添加养殖信息
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// 
        [HttpPost]
        public async Task<APIResult<Farms>> CreateFarm(CreateFarmCommends request, CancellationToken cancellationToken)
        {
            return await mediator.Send(request, cancellationToken);
        }
    }
}
